#define PioDiamond

float noise(float t)
{
	return fract(cos(t) * 3800.);
}

vec3 lensflare(vec2 u,vec2 pos)
{
	vec2 main = u-pos;
	vec2 uvd = u*(length(u));
	highp float intensity = 0.7;
	
	float ang = atan(main.y, main.x);
	float dist=length(u); //main
  dist = pow(dist,.01);
	float n = noise(0.);
	
	float f0 = (1.0/(length(u-12.)*16.0+1.0)) * 1.;
	
	f0 = f0*(sin((n*2.0)*12.0)*.1+dist*.1+.8);

	float f2 = max(1.0/(1.0+32.0*pow(length(uvd+0.8*pos),2.0)),.0)*00.25;
	float f22 = max(1.0/(1.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*00.23;
	float f23 = max(1.0/(1.0+32.0*pow(length(uvd+0.9*pos),2.0)),.0)*00.21;
	
	vec2 uvx = mix(u,uvd,-0.5);
	
	float f4 = max(0.02-pow(length(uvx+0.45*pos),2.4),.0)*7.0;
	float f42 = max(0.02-pow(length(uvx+0.5*pos),2.4),.0)*4.0;
	float f43 = max(0.02-pow(length(uvx+0.55*pos),2.4),.0)*2.0;
	
	uvx = mix(u,uvd,-.4);
	
	float f5 = max(0.02-pow(length(uvx+0.3*pos),5.5),.0)*2.0;
	float f52 = max(0.02-pow(length(uvx+0.5*pos),5.5),.0)*2.0;
	float f53 = max(0.01-pow(length(uvx+0.7*pos),5.5),.0)*2.0;
	
	uvx = mix(u,uvd,-0.5);
	
	float f6 = max(0.02-pow(length(uvx+0.1*pos),1.6),.0)*8.0;
	float f62 = max(0.01-pow(length(uvx+0.125*pos),1.6),.0)*4.0;
	float f63 = max(0.01-pow(length(uvx+0.15*pos),1.6),.0)*7.0;
	
	highp vec3 c = vec3(0.0);
	c.r+=f2, f42; 
	c.g+=f2, f42; 
	c.b+=f2, f42; 
  
	c+=vec3(f0);
	
	return c * intensity;
}

vec3 cc(vec3 color, float factor,float factor2) // color modifier
{
	float w = color.x+color.y+color.z;
	return mix(color,vec3(w)*factor,w*factor2);
}
